﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.codeplex.com/MSSqlSchemaDoc"
  xmlns="http://www.codeplex.com/MSSqlSchemaDoc"
  attributeFormDefault="unqualified"
  elementFormDefault="qualified">

  <xs:include schemaLocation="ColumnDocumentationType.xsd" />

  <xs:element name="TableDocumentation">
    <xs:complexType>
      <xs:sequence>

        <xs:element name="Documentation" type="xs:string" />

        <xs:element name="Columns">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="1" maxOccurs="unbounded" name="ColumnDocumentation" type="ColumnDocumentationType" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="Triggers">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="TableTriggerDocumentation">
                
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Documentation" type="xs:string" />
                  </xs:sequence>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                  <xs:attribute name="Schema" type="xs:string" use="required" />
                </xs:complexType>
                
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="Indexes">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="IndexDocumentation">

                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Documentation" type="xs:string" />
                  </xs:sequence>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                </xs:complexType>

              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="ForeignKeys">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="unbounded" name="ForeignKeyDocumentation">

                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Documentation" type="xs:string" />
                  </xs:sequence>
                  <xs:attribute name="Name" type="xs:string" use="required" />
                </xs:complexType>

              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        
      </xs:sequence>
      
      <xs:attribute name="Name" type="xs:string" use="required" />
      <xs:attribute name="Schema" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>
</xs:schema>